Using
an Event Callback to Process Driver Messages
To use an
event callback, use the CreateEvent function to retrieve the handle of
an event. In the call to the waveOutOpen2MUO.P_ function, specify CALLBACK_EVENT for the fdwOpen
parameter. After calling the waveOutPrepareHeader1MF2IJO function but before
sending waveform-audio data to the device, create a nonsignaled event by
calling the ResetEvent function, specifying the event handle retrieved
by CreateEvent. Then, inside a loop that checks whether the WHDR_DONE
bit is set in the dwFlags member of the WAVEHDR3CAL0JU structure, call the WaitForSingleObjectJ9IQ2G function, specifying as
parameters the event handle and a time-out value of INFINITE.
Because event
callbacks do not receive specific close, done, or open notifications, an application
might have to check the status of the process it is waiting for after the event
occurs. It is possible that a number of tasks could have been completed by the
time WaitForSingleObject returns.